Function Reference

_TS_Open

Opens a connection to the Microsoft Task Scheduler Service on the local or a remote computer.

#Include <TaskScheduler.au3>
_TS_Open([$sComputer[, $sUser[, $sDomain[, $sPassword]]]])

 

Parameters

$sComputer [optional] The name of the computer that you want to connect to. If this parameter is empty, the function will connect to the local computer.
$sUser [optional] The user name that is used during the connection to $sComputer. If the user is not specified, then the current token is used.
$sDomain [optional] The domain of the user specified in the user parameter.
$sPassword [optional] The password that is used to connect to $sComputer. If user name and password are not specified, the current token is used.

 

Return Value

Success: Object of the Task Scheduler Service
Failure: Returns 0 and sets @error:
    101 - Error creating the COM error handler. @extended is set to the error code returned by _TS_ErrorNotify
    102 - Error creating the Task Scheduler Service. @extended is set to the COM error code
    103 - Error connecting to the Task Scheduler Service. @extended is set to the COM error code:
    0x80070005 - Access is denied to connect to the Task Scheduler service.
    0x8007000e - The application does not have enough memory to complete the operation or
    the user, password, or domain has at least one null and one non-null value.
    53 - This error is returned in the following situations:
    The computer name specified in the serverName parameter does not exist.
    When you are trying to connect to a Windows Server 2003 or Windows XP computer, and the remote computer does not have the
    File and Printer Sharing firewall exception enabled or the Remote Registry service is not running.
    When you are trying to connect to a Windows Vista computer, and the remote computer does not have the
    Remote Scheduled Tasks Management firewall exception enabled and the File and Printer Sharing firewall exception enabled, or the Remote Registry service is not running.
    50 - The user, password, or domain parameters cannot be specified when connecting to a remote Windows XP or Windows Server 2003 computer from a Windows Vista computer.

 

Remarks

$sComputer can be specified as name or IP-Address. Name is network\computername or \\computername

 

Related

 

Example


#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <TaskScheduler.au3>
_TS_ErrorNotify(2)
Global $aTasks, $oService, $sComputer = "", $sUser = "", $sDomain = "", $sPassword = ""
$sComputer = InputBox("_TS_Open", "Please enter the Computer you want to connect to." & @CRLF & _
        "This is either the computer name when in AD or the IP-address if not." & @CRLF & "If set to '*' you connect to the local computer!", "", "", 450, 150)
If @error Then Exit
If $sComputer = "*" Then $sComputer = @ComputerName
$sUser = InputBox("_TS_Open", "Please enter the UserId you want to use to connect to the specified computer! Use one of the following:" & @CRLF & _
        "* AD user which is in the local Administrators group on that computer, via domain or local group, or directly. Use AD computer name." & @CRLF & _
        "* Local user (Administrator) which is NOT an AD user, and is in the local Administrators group on that computer, via local group, or directly. Use AD computer name." & @CRLF & _
        "* Non-domain computer where the entered local user (Administrator) is in the local Administrators group on that computer. Use IP address or DNS name to connect.", "", "", 850, 170)
If @error Then Exit
$sDomain = InputBox("_TS_Open", "Please enter the Domain of the entered UserId!" & @CRLF & _
        "Enter the domain name when using an AD user and '.' if using a local user.", "", "", 450, 150)
If @error Then Exit
$sPassword = InputBox("_TS_Open", "Please enter the Password for the UserId!", "", "*", 450, 150)
If @error Then Exit
$oService = _TS_Open($sComputer, $sUser, $sDomain, $sPassword)
If @error Then Exit MsgBox($MB_ICONERROR, "_TS_Open", "_TS_Open returned @error=" & @error & ", @extended=" & @extended & @CRLF & @CRLF & _TS_ErrorText(@error))
$aTasks = _TS_TaskList($oService)
If @error Then Exit MsgBox($MB_ICONERROR, "_TS_Open", "_TS_TaskList returned @error=" & @error & ", @extended=" & @extended & @CRLF & @CRLF & _TS_ErrorText(@error))
_ArrayDisplay($aTasks)
_TS_Close()